
const Koa=require('koa')

const app=new Koa();

const router=require('koa-router')();

router.get('/list',async ctx=>
{
    ctx.body={
        code:0,
        mes:"list接口"
    }
})
router.get('/detail/:id',async ctx=>
{
    console.log(ctx.params);
    ctx.body={
        code:0,
        mes:"detail接口"
    }
})
router.post('/login',async ctx=>
{
    ctx.body={
        code:0,
        phone,
        pwd,
        mes:"login接口"
    }
})

app.use(router.routes());//挂载路由
app.use(router.allowedMethods());
app.listen(3000)

/* app.use(async (ctx,next)=>
{
    console.log("1");
    await next();
    console.log("3");
})
app.use(async (ctx)=>
{
    console.log("2");
}) */
/* let play=()=>new Promise((res,rej)=>
{
    setTimeout(() => {
        res()
    }, 1000);
}) */
/* app.listen(3000) */